# This is a sample Python script.

# Press ⇧F10 to execute it or replace it with your code.
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.
import unittest
from utils.creat_report import CreatReport
from base.run_case import RunSuit
from common.mail import SendMail
from utils.ini import OperationIni


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    suit = unittest.TestSuite()
    suit.addTest(unittest.makeSuite(RunSuit))
    report = CreatReport()
    report.creat_report(suit)
    send_report = OperationIni().read_cfg('sysconfig', 'mail')
    print(f'send mail is {send_report}')
    if send_report == 'on':
        report_file = report.get_report_file()
        mail = SendMail()
        sub = '测试报告'
        msg = f'用例执行总数 {suit.countTestCases()} 条，检查测试成功用例 {RunSuit.pass_count} 条， 检查测试失败用例 {RunSuit.fill_count} 条'
        mail.send_mail(sub=sub, msg=msg, file=report_file)
# See PyCharm help at https://www.jetbrains.com/help/pycharm/
